import path from "path";
import type { StorybookConfig } from "@storybook/react-vite";
import { mergeConfig } from "vite";
const config: StorybookConfig = {
  stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],

  addons: [
    path.dirname(
      require.resolve(path.join("@storybook/addon-links", "package.json"))
    ),
    path.dirname(
      require.resolve(path.join("@storybook/addon-essentials", "package.json"))
    ),
    path.dirname(
      require.resolve(
        path.join("@storybook/addon-interactions", "package.json")
      )
    ),
  ],
  framework: {
    name: "@storybook/react-vite",
    options: {},
  },

  docs: {
    autodocs: "tag",
  },
  // previewMainTemplate: ".storybook/template.ejs",
  managerHead(head) {
    return `
      ${head}
      <div>loading</div>
      <script  src="https://test-scm.kxgcc.com:30195/public/js/auth-umd/index.umd.js"></script>
      <script type="module">
        const thing = new CoreAuthSdk.Thing({
          path: "https://test-scm.kxgcc.com:30195/auth",
          pt: 2,
        });



        thing.init();

      </script>
    `;
  },
  async viteFinal(config) {
    return mergeConfig(config, {
      server: {
        proxy: {
          "/api": {
            target: "https://test-scm.kxgcc.com:30195",
            changeOrigin: true,
            secure: false,
          },
        },
      },
    });
  },
};
export default config;
